<#assign classNamevar = className?uncap_first/>
app.controller("${classNamevar}Controller", function ($scope, $http,$controller,${classNamevar}Service) {

    $controller('baseController',{$scope:$scope})
    //查询品牌列表
    $scope.findAll = function () {
        ${classNamevar}Service.findAll().success(function (response) {
            console.log(response)
            $scope.list = response
        })
    }

    //分页查询
    $scope.searchEntity = {}
    $scope.search = function (page, size) {
        ${classNamevar}Service.search(page, size,$scope.searchEntity)
            .success(function (response) {
                $scope.list = response.list //更新当前页数据
                $scope.paginationConf.totalItems = response.total//更新总记录数
            })
    }
    //刷新数据
    $scope.reloadList=function () {
        $scope.search($scope.paginationConf.currentPage,$scope.paginationConf.itemsPerPage)
    }
    //http://localhost:9101/brand/findPage.do?pageNum=3&pageSize=10
    $scope.findPage = function (page, size) {
        ${classNamevar}Service.findPage(page,size)
            .success(function (response) {
                $scope.list = response.list //更新当前页数据
                $scope.paginationConf.totalItems = response.total//更新总记录数
            })
    }

    $scope.findOne = function (id) {
        ${classNamevar}Service.findOne(id)
            .success(function (response) {
                $scope.entity = response
            })
    }

    $scope.del = function () {
        ${classNamevar}Service.del($scope.selectIds)
            .success(function (response) {
                if (response.flag) {
                    $scope.reloadList()
                    $scope.selectIds = []
                } else {
                    alert(response.message);
                }
            })
    }
    $scope.save = function () {
        var object;
        if ($scope.entity.id) {
            object = ${classNamevar}Service.update($scope.entity)
        }else{
            object = ${classNamevar}Service.add($scope.entity)
        }

        object.success(function (response) {
            if (response.flag) {
                $scope.reloadList()
            } else {
                alert(response.message);
            }
        })
    }



})